class Seiso::ImportMaster
  # Author:: Willie Wheeler
  # Copyright:: Copyright (c) 2014-2016 Expedia, Inc.
  # License:: Apache 2.0
  class Mappers::NodeMapper

    def initialize(resolver)
      @resolver = resolver
      @health_unknown = @resolver.item_uri('healthStatuses', 'unknown')
      @rotation_unknown = @resolver.item_uri('rotationStatuses', 'unknown')
    end

    # TODO Need to map POSTs and PATCHes differently.
    # POSTs should contain unknown statuses. PATCHes shouldn't.

    # TODO Do we even need to provide the unknowns here?
    # Doesn't/shouldn't the API automatically set this?

    # Maps a document node to a Seiso node. Does *not* map state-related fields, such as buildVersion, healthStatus and
    # aggregateRotationStatus.
    #
    # - doc_node : document node
    def map(doc_node, context)
      {
        'name' => doc_node['name'],
        'description' => doc_node['description'],
        'serviceInstance' => context['serviceInstance'].self.href,
        'machine' => @resolver.item_uri('machines', doc_node['machine'])
#        'healthStatus' => @health_unknown
      }
    end
  end
end
